package com.xyzh05.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

import org.compass.annotations.Searchable;
import org.compass.annotations.SearchableId;
import org.compass.annotations.SearchableProperty;

@Entity
@Table(name="material")
@Searchable
@XmlRootElement
public class Material extends BaseObject implements Serializable {
	private static final long serialVersionUID = 8352096161121135073L;
	
	private Long id;
    private VipService vipService;
    private School school;
    private User user;
    private Long applyDegree;
    private Major applyMajor;
    private Date updateTime = new Date();
    private Short status = 0;
    private Short scoreCheck;
    private Short readingCheck;
    private Short psCheck;
    private Short cvCheck;
    private Short rlCheck;
    private Short essayCheck;
    private Short rankingCheck;
    private Short honourCheck;
    private Short assetsCheck;
    private Short gtCheck;
    private Short instituteCheck;
    private Short materialListCheck;
    private Short finalCheck;
    private MaterialInfo materialInfo = new MaterialInfo();

    @Id @GeneratedValue(strategy=GenerationType.AUTO) @SearchableId    
    public Long getId() {
        return this.id;
    }
    
    public void setId(Long id) {
        this.id = id;
    }

    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="service_id", nullable=false)
    public VipService getVipService() {
        return this.vipService;
    }
    
    public void setVipService(VipService vipService) {
        this.vipService = vipService;
    }

    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="school_id", nullable=false)
    public School getSchool() {
        return this.school;
    }
    
    public void setSchool(School school) {
        this.school = school;
    }
    
	@OneToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="update_user")
    public User getUser() {
        return this.user;
    }
    
    public void setUser(User user) {
        this.user = user;
    }
    
    @Column(name="apply_degree")
    @SearchableProperty
    public Long getApplyDegree() {
        return this.applyDegree;
    }
    
    public void setApplyDegree(Long applyDegree) {
        this.applyDegree = applyDegree;
    }
    
    @OneToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="apply_major", nullable=false)
    public Major getApplyMajor() {
        return this.applyMajor;
    }
    
    public void setApplyMajor(Major applyMajor) {
        this.applyMajor = applyMajor;
    }
    
    @Column(name="update_time", nullable=false)
    @SearchableProperty
    public Date getUpdateTime() {
        return this.updateTime;
    }
    
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    
    @Column(name="status", nullable=false)
    @SearchableProperty
    public Short getStatus() {
        return this.status;
    }
    
    public void setStatus(Short status) {
        this.status = status;
    }
    
    @Column(name="score_check")
    @SearchableProperty
    public Short getScoreCheck() {
        return this.scoreCheck;
    }
    
    public void setScoreCheck(Short scoreCheck) {
        this.scoreCheck = scoreCheck;
    }
    
    @Column(name="reading_check")
    @SearchableProperty
    public Short getReadingCheck() {
        return this.readingCheck;
    }
    
    public void setReadingCheck(Short readingCheck) {
        this.readingCheck = readingCheck;
    }
    
    @Column(name="ps_check")
    @SearchableProperty
    public Short getPsCheck() {
        return this.psCheck;
    }
    
    public void setPsCheck(Short psCheck) {
        this.psCheck = psCheck;
    }
    
    @Column(name="cv_check")
    @SearchableProperty
    public Short getCvCheck() {
        return this.cvCheck;
    }
    
    public void setCvCheck(Short cvCheck) {
        this.cvCheck = cvCheck;
    }
    
    @Column(name="rl_check")
    @SearchableProperty
    public Short getRlCheck() {
        return this.rlCheck;
    }
    
    public void setRlCheck(Short rlCheck) {
        this.rlCheck = rlCheck;
    }
    
    @Column(name="essay_check")
    @SearchableProperty
    public Short getEssayCheck() {
        return this.essayCheck;
    }
    
    public void setEssayCheck(Short essayCheck) {
        this.essayCheck = essayCheck;
    }
    
    @Column(name="ranking_check")
    @SearchableProperty
    public Short getRankingCheck() {
        return this.rankingCheck;
    }
    
    public void setRankingCheck(Short rankingCheck) {
        this.rankingCheck = rankingCheck;
    }
    
    @Column(name="honour_check")
    @SearchableProperty
    public Short getHonourCheck() {
        return this.honourCheck;
    }
    
    public void setHonourCheck(Short honourCheck) {
        this.honourCheck = honourCheck;
    }
    
    @Column(name="assets_check")
    @SearchableProperty
    public Short getAssetsCheck() {
        return this.assetsCheck;
    }
    
    public void setAssetsCheck(Short assetsCheck) {
        this.assetsCheck = assetsCheck;
    }
    
    @Column(name="gt_check")
    @SearchableProperty
    public Short getGtCheck() {
        return this.gtCheck;
    }
    
    public void setGtCheck(Short gtCheck) {
        this.gtCheck = gtCheck;
    }
    
    @Column(name="institute_check")
    @SearchableProperty
    public Short getInstituteCheck() {
        return this.instituteCheck;
    }
    
    public void setInstituteCheck(Short instituteCheck) {
        this.instituteCheck = instituteCheck;
    }
    
    @Column(name="material_list_check")
    @SearchableProperty
    public Short getMaterialListCheck() {
        return this.materialListCheck;
    }
    
    public void setMaterialListCheck(Short materialListCheck) {
        this.materialListCheck = materialListCheck;
    }

    @Column(name="final_check")
    @SearchableProperty
    public Short getFinalCheck() {
		return finalCheck;
	}

	public void setFinalCheck(Short finalCheck) {
		this.finalCheck = finalCheck;
	}

	@OneToOne(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="material")
    public MaterialInfo getMaterialInfo() {
		return materialInfo;
	}

	public void setMaterialInfo(MaterialInfo materialInfo) {
		this.materialInfo = materialInfo;
	}
	
	public Material(){		
	}
	
	public Material(Long id, School school){
		this.id = id;
		this.school = school;
	}

	public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Material pojo = (Material) o;

        if (vipService != null ? !vipService.equals(pojo.vipService) : pojo.vipService != null) return false;
        if (school != null ? !school.equals(pojo.school) : pojo.school != null) return false;
        if (user != null ? !user.equals(pojo.user) : pojo.user != null) return false;
        if (applyDegree != null ? !applyDegree.equals(pojo.applyDegree) : pojo.applyDegree != null) return false;
        if (applyMajor != null ? !applyMajor.equals(pojo.applyMajor) : pojo.applyMajor != null) return false;
        if (updateTime != null ? !updateTime.equals(pojo.updateTime) : pojo.updateTime != null) return false;
        if (status != null ? !status.equals(pojo.status) : pojo.status != null) return false;
        if (scoreCheck != null ? !scoreCheck.equals(pojo.scoreCheck) : pojo.scoreCheck != null) return false;
        if (readingCheck != null ? !readingCheck.equals(pojo.readingCheck) : pojo.readingCheck != null) return false;
        if (psCheck != null ? !psCheck.equals(pojo.psCheck) : pojo.psCheck != null) return false;
        if (cvCheck != null ? !cvCheck.equals(pojo.cvCheck) : pojo.cvCheck != null) return false;
        if (rlCheck != null ? !rlCheck.equals(pojo.rlCheck) : pojo.rlCheck != null) return false;
        if (essayCheck != null ? !essayCheck.equals(pojo.essayCheck) : pojo.essayCheck != null) return false;
        if (rankingCheck != null ? !rankingCheck.equals(pojo.rankingCheck) : pojo.rankingCheck != null) return false;
        if (honourCheck != null ? !honourCheck.equals(pojo.honourCheck) : pojo.honourCheck != null) return false;
        if (assetsCheck != null ? !assetsCheck.equals(pojo.assetsCheck) : pojo.assetsCheck != null) return false;
        if (gtCheck != null ? !gtCheck.equals(pojo.gtCheck) : pojo.gtCheck != null) return false;
        if (instituteCheck != null ? !instituteCheck.equals(pojo.instituteCheck) : pojo.instituteCheck != null) return false;
        if (materialListCheck != null ? !materialListCheck.equals(pojo.materialListCheck) : pojo.materialListCheck != null) return false;
        if (finalCheck != null ? !finalCheck.equals(pojo.finalCheck) : pojo.finalCheck != null) return false;

        return true;
    }

    public int hashCode() {
        int result = 0;
        result = (vipService != null ? vipService.hashCode() : 0);
        result = 31 * result + (school != null ? school.hashCode() : 0);
        result = 31 * result + (user != null ? user.hashCode() : 0);
        result = 31 * result + (applyDegree != null ? applyDegree.hashCode() : 0);
        result = 31 * result + (applyMajor != null ? applyMajor.hashCode() : 0);
        result = 31 * result + (updateTime != null ? updateTime.hashCode() : 0);
        result = 31 * result + (status != null ? status.hashCode() : 0);
        result = 31 * result + (scoreCheck != null ? scoreCheck.hashCode() : 0);
        result = 31 * result + (readingCheck != null ? readingCheck.hashCode() : 0);
        result = 31 * result + (psCheck != null ? psCheck.hashCode() : 0);
        result = 31 * result + (cvCheck != null ? cvCheck.hashCode() : 0);
        result = 31 * result + (rlCheck != null ? rlCheck.hashCode() : 0);
        result = 31 * result + (essayCheck != null ? essayCheck.hashCode() : 0);
        result = 31 * result + (rankingCheck != null ? rankingCheck.hashCode() : 0);
        result = 31 * result + (honourCheck != null ? honourCheck.hashCode() : 0);
        result = 31 * result + (assetsCheck != null ? assetsCheck.hashCode() : 0);
        result = 31 * result + (gtCheck != null ? gtCheck.hashCode() : 0);
        result = 31 * result + (instituteCheck != null ? instituteCheck.hashCode() : 0);
        result = 31 * result + (materialListCheck != null ? materialListCheck.hashCode() : 0);
        result = 31 * result + (finalCheck != null ? finalCheck.hashCode() : 0);

        return result;
    }

    public String toString() {
        StringBuffer sb = new StringBuffer(getClass().getSimpleName());

        sb.append(" [");
        sb.append("id").append("='").append(getId()).append("', ");
        sb.append("vipService").append("='").append(getVipService()).append("', ");
        sb.append("school").append("='").append(getSchool()).append("', ");
        sb.append("user").append("='").append(getUser()).append("', ");
        sb.append("applyDegree").append("='").append(getApplyDegree()).append("', ");
        sb.append("applyMajor").append("='").append(getApplyMajor()).append("', ");
        sb.append("updateTime").append("='").append(getUpdateTime()).append("', ");
        sb.append("status").append("='").append(getStatus()).append("', ");
        sb.append("scoreCheck").append("='").append(getScoreCheck()).append("', ");
        sb.append("readingCheck").append("='").append(getReadingCheck()).append("', ");
        sb.append("psCheck").append("='").append(getPsCheck()).append("', ");
        sb.append("cvCheck").append("='").append(getCvCheck()).append("', ");
        sb.append("rlCheck").append("='").append(getRlCheck()).append("', ");
        sb.append("essayCheck").append("='").append(getEssayCheck()).append("', ");
        sb.append("rankingCheck").append("='").append(getRankingCheck()).append("', ");
        sb.append("honourCheck").append("='").append(getHonourCheck()).append("', ");
        sb.append("assetsCheck").append("='").append(getAssetsCheck()).append("', ");
        sb.append("gtCheck").append("='").append(getGtCheck()).append("', ");
        sb.append("instituteCheck").append("='").append(getInstituteCheck()).append("', ");
        sb.append("materialListCheck").append("='").append(getMaterialListCheck()).append("', ");
        sb.append("finalCheck").append("='").append(getFinalCheck()).append("', ");
        sb.append("]");
      
        return sb.toString();
    }

}
